/*
 * ClienteGUI.java
 *
 * Created on 3 de Maio de 2008, 19:27
 */
package Cliente;


import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
 *
 * @author  Administrador
 */
public class ClienteGUI extends javax.swing.JFrame {
    Cliente cliente;
    /** Creates new form ClienteGUI */
    public ClienteGUI() {
        initComponents();
         cliente = new Cliente(this);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jDesktopPane1 = new javax.swing.JDesktopPane();
        tfNome = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        tfNovaSenha = new javax.swing.JTextField();
        btTrocar = new javax.swing.JButton();
        jDesktopPane2 = new javax.swing.JDesktopPane();
        jLabel3 = new javax.swing.JLabel();
        tfNomeShutdown = new javax.swing.JTextField();
        btDesligar = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        tfTempo = new javax.swing.JTextField();
        jDesktopPane3 = new javax.swing.JDesktopPane();
        jLabel4 = new javax.swing.JLabel();
        btExecutar = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        tfNomeComando = new javax.swing.JTextField();
        tfComando = new javax.swing.JTextField();
        jDesktopPane4 = new javax.swing.JDesktopPane();
        tfNomeReiniciar = new javax.swing.JTextField();
        tfTempoReiniciar = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        btReiniciar = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        tfNome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfNomeActionPerformed(evt);
            }
        });
        tfNome.setBounds(110, 20, 100, -1);
        jDesktopPane1.add(tfNome, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel1.setText("naming.bind():");
        jLabel1.setBounds(30, 20, 90, 20);
        jDesktopPane1.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel2.setText("Nova Senha:");
        jLabel2.setBounds(30, 50, 70, 20);
        jDesktopPane1.add(jLabel2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        tfNovaSenha.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfNovaSenhaActionPerformed(evt);
            }
        });
        tfNovaSenha.setBounds(110, 50, 100, -1);
        jDesktopPane1.add(tfNovaSenha, javax.swing.JLayeredPane.DEFAULT_LAYER);

        btTrocar.setText("Trocar");
        btTrocar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btTrocarActionPerformed(evt);
            }
        });
        btTrocar.setBounds(110, 90, -1, -1);
        jDesktopPane1.add(btTrocar, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTabbedPane1.addTab("Senha Administrador", jDesktopPane1);

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel3.setText("naming.bind():");
        jLabel3.setBounds(30, 20, 90, 20);
        jDesktopPane2.add(jLabel3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        tfNomeShutdown.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfNomeShutdownActionPerformed(evt);
            }
        });
        tfNomeShutdown.setBounds(110, 20, 100, -1);
        jDesktopPane2.add(tfNomeShutdown, javax.swing.JLayeredPane.DEFAULT_LAYER);

        btDesligar.setText("Desligar");
        btDesligar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btDesligarActionPerformed(evt);
            }
        });
        btDesligar.setBounds(110, 90, 73, -1);
        jDesktopPane2.add(btDesligar, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel6.setText("Tempo(segundos):");
        jLabel6.setBounds(30, 50, 110, 20);
        jDesktopPane2.add(jLabel6, javax.swing.JLayeredPane.DEFAULT_LAYER);

        tfTempo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfTempoActionPerformed(evt);
            }
        });
        tfTempo.setBounds(150, 50, 60, -1);
        jDesktopPane2.add(tfTempo, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTabbedPane1.addTab("Desligar", jDesktopPane2);

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel4.setText("Comando :");
        jLabel4.setBounds(30, 50, 60, -1);
        jDesktopPane3.add(jLabel4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        btExecutar.setText("Executar");
        btExecutar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btExecutarActionPerformed(evt);
            }
        });
        btExecutar.setBounds(100, 100, -1, -1);
        jDesktopPane3.add(btExecutar, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel5.setText("naming.bind():");
        jLabel5.setBounds(30, 20, 90, 20);
        jDesktopPane3.add(jLabel5, javax.swing.JLayeredPane.DEFAULT_LAYER);

        tfNomeComando.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfNomeComandoActionPerformed(evt);
            }
        });
        tfNomeComando.setBounds(110, 20, 100, -1);
        jDesktopPane3.add(tfNomeComando, javax.swing.JLayeredPane.DEFAULT_LAYER);

        tfComando.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfComandoActionPerformed(evt);
            }
        });
        tfComando.setBounds(110, 50, 170, -1);
        jDesktopPane3.add(tfComando, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTabbedPane1.addTab("Comando Personalizado", jDesktopPane3);

        tfNomeReiniciar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfNomeReiniciarActionPerformed(evt);
            }
        });
        tfNomeReiniciar.setBounds(110, 20, 100, -1);
        jDesktopPane4.add(tfNomeReiniciar, javax.swing.JLayeredPane.DEFAULT_LAYER);

        tfTempoReiniciar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfTempoReiniciarActionPerformed(evt);
            }
        });
        tfTempoReiniciar.setBounds(150, 50, 60, -1);
        jDesktopPane4.add(tfTempoReiniciar, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel7.setText("Tempo(segundos):");
        jLabel7.setBounds(30, 50, 110, 20);
        jDesktopPane4.add(jLabel7, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel8.setText("naming.bind():");
        jLabel8.setBounds(30, 20, 90, 20);
        jDesktopPane4.add(jLabel8, javax.swing.JLayeredPane.DEFAULT_LAYER);

        btReiniciar.setText("Reiniciar");
        btReiniciar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btReiniciarActionPerformed(evt);
            }
        });
        btReiniciar.setBounds(110, 90, 73, -1);
        jDesktopPane4.add(btReiniciar, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTabbedPane1.addTab("Reiniciar", jDesktopPane4);

        jMenu1.setText("menu");
        jMenu1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu1ActionPerformed(evt);
            }
        });

        jMenuItem1.setText("Sair");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 698, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 483, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void tfNomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfNomeActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_tfNomeActionPerformed

    private void tfNovaSenhaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfNovaSenhaActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_tfNovaSenhaActionPerformed

    private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu1ActionPerformed
        // TODO add your handling code here:
        System.exit(0);
    }//GEN-LAST:event_jMenu1ActionPerformed

    private void btTrocarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btTrocarActionPerformed
        // TODO add your handling code here:
//        cliente.conecta(tfNome.getText());
        cliente.rodaComando("net user administrador "+tfNovaSenha.getText());
    }//GEN-LAST:event_btTrocarActionPerformed

    private void tfNomeShutdownActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfNomeShutdownActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_tfNomeShutdownActionPerformed

    private void btDesligarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDesligarActionPerformed
        // TODO add your handling code here:
//        cliente.conecta(tfNomeShutdown.getText());
        cliente.rodaComando("shutdown -s -t "+tfTempo.getText());
}//GEN-LAST:event_btDesligarActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
        System.exit(0);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void tfTempoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfTempoActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_tfTempoActionPerformed

    private void tfNomeReiniciarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfNomeReiniciarActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_tfNomeReiniciarActionPerformed

    private void tfTempoReiniciarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfTempoReiniciarActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_tfTempoReiniciarActionPerformed

    private void btReiniciarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btReiniciarActionPerformed
        // TODO add your handling code here:
        cliente.conecta(tfNomeShutdown.getText());
        cliente.rodaComando("shutdown -r -t "+tfTempo.getText());
}//GEN-LAST:event_btReiniciarActionPerformed

    private void btExecutarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btExecutarActionPerformed
        // TODO add your handling code here:
        cliente.conecta(tfNomeComando.getText());
        cliente.rodaComando(tfComando.getText());
    }//GEN-LAST:event_btExecutarActionPerformed

    private void tfComandoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfComandoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfComandoActionPerformed

    private void tfNomeComandoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfNomeComandoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfNomeComandoActionPerformed
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        try {
            // Set System L&F
            UIManager.setLookAndFeel(
                    UIManager.getSystemLookAndFeelClassName());
        } catch (UnsupportedLookAndFeelException e) {
        // handle exception
        } catch (ClassNotFoundException e) {
        // handle exception
        } catch (InstantiationException e) {
        // handle exception
        } catch (IllegalAccessException e) {
        // handle exception
        }

        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new ClienteGUI().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btDesligar;
    private javax.swing.JButton btExecutar;
    private javax.swing.JButton btReiniciar;
    private javax.swing.JButton btTrocar;
    private javax.swing.JDesktopPane jDesktopPane1;
    private javax.swing.JDesktopPane jDesktopPane2;
    private javax.swing.JDesktopPane jDesktopPane3;
    private javax.swing.JDesktopPane jDesktopPane4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField tfComando;
    private javax.swing.JTextField tfNome;
    private javax.swing.JTextField tfNomeComando;
    private javax.swing.JTextField tfNomeReiniciar;
    private javax.swing.JTextField tfNomeShutdown;
    private javax.swing.JTextField tfNovaSenha;
    private javax.swing.JTextField tfTempo;
    private javax.swing.JTextField tfTempoReiniciar;
    // End of variables declaration//GEN-END:variables
}
